Click here to return to the VHDL Reference Guide. (last edit: 24. september 2012)

File

A file is a stream of values of a specified type which can be read or written during simulation. Files belong to a special kind of data type called a file type. The only files which are commonly used are text files, read or written using package TEXTIO.

Syntax

  type NewName is file of TypeName;

  file NewName: DataType is [Mode] FileName;                          {'87 only}
  Mode = {either} in out                                              {'87 only}

  file NewName: DataType open FileKind is FileName;
  FileKind = {either} Read_mode Write_mode Append_mode

  FileName = StringExpression
    

Where

See Declaration

Rules

The following are defined implicitly for all file types: procedure FILE_OPEN ( file F: FT; External_name: in STRING; Open_kind: in FILE_OPEN_KIND := READ_MODE); procedure FILE_OPEN ( Status: out FILE_OPEN_STATUS; file F: FT; External_name: in STRING; Open_kind: in FILE_OPEN_KIND := READ_MODE); procedure FILE_CLOSE ( file F: FT); procedure READ ( file F: FT; VALUE: out TM); procedure WRITE ( file F: FT; VALUE: in TM); function ENDFILE ( file F: FT) return BOOLEAN;

Things to remember

File declarations are incompatible between VHDL'87 and VHDL'93. Files (except those written using TEXTIO) cannot necessarily be read into another VHDL simulator, or even be read using a standard text editor!

Synthesis

Files are not synthesizable.

Tips

Always use package TEXTIO to read or write files.

Example

  type T2 is file of T1;
  file F: T2 is out "filename";             -- VHDL'87
  file F: T2 open Write_mode is "filename"; -- VHDL'93
    

See Also

TEXTIO, Type